package com.buaa.controller;

import com.buaa.common.Result;
import com.buaa.service.ITrafficCaseInfoService;
import com.buaa.vo.traffic.CaseVO;
import com.buaa.vo.traffic.TimeVO;
import com.buaa.vo.traffic.TrafficCountVO;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequiredArgsConstructor
@RequestMapping("traffic")
public class TrafficCaseInfoController {

    private final ITrafficCaseInfoService trafficCaseInfoService;

    @GetMapping("count")
    public Result<List<TrafficCountVO>> trafficCount(@RequestParam("adcode") Integer adcode) {
        return Result.success(trafficCaseInfoService.trafficCount(adcode));
    }

    @GetMapping("gender")
    public Result<List<TrafficCountVO>> countGender(@RequestParam("adcode") Integer adcode) {
        List<TrafficCountVO> list = trafficCaseInfoService.countGender(adcode);
        return Result.success(list);
    }

    @GetMapping("career")
    public Result<List<TrafficCountVO>> countCareer(@RequestParam("limit") Integer limit,@RequestParam("adcode") Integer adcode) {
        return Result.success(trafficCaseInfoService.countCareer(limit,adcode));
    }

    @GetMapping("cases")
    public Result<List<CaseVO>> lastCases(@RequestParam("limit") Integer limit,@RequestParam("adcode") Integer adcode) {
        return Result.success(trafficCaseInfoService.getLastCases(limit,adcode));
    }

    @GetMapping("time")
    public Result<TimeVO> countTime(@RequestParam("adcode") Integer adcode) {
        return Result.success(trafficCaseInfoService.countTime(adcode));
    }

    @GetMapping("edu")
    public Result<List<TrafficCountVO>> education(@RequestParam("adcode") Integer adcode) {
        return Result.success(trafficCaseInfoService.educationCount(adcode));
    }

    @GetMapping("windSpeed")
    public Result<List<TrafficCountVO>> windSpeed(@RequestParam("adcode") Integer adcode) {
        return Result.success(trafficCaseInfoService.windSpeedCount(adcode));
    }
}
